package com.lemon.core.base.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * Entity基类
 *
 * @author pan
 * @since 2018-03-05
 */
@Data
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String CREATE_TIME = "create_time";
    public static final String CREATE_TIME_FIELD = "createTime";
    public static final String CREATE_BY = "create_by";
    public static final String CREATE_BY_FIELD = "createBy";
    public static final String UPDATE_TIME = "update_time";
    public static final String UPDATE_TIME_FIELD = "updateTime";
    public static final String UPDATE_BY = "update_by";
    public static final String UPDATE_BY_FIELD = "updateBy";
    public static final String DEL_FLAG = "del_flag";
    public static final String ID_FIELD = "id";

    @TableId(value = ID_FIELD, type = IdType.ASSIGN_ID)
    protected Long id;

    @TableField(value = CREATE_TIME, fill = FieldFill.INSERT)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @TableField(value = CREATE_BY, fill = FieldFill.INSERT)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private String createBy;

    @TableField(value = UPDATE_TIME, fill = FieldFill.INSERT_UPDATE)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @TableField(value = UPDATE_BY, fill = FieldFill.INSERT_UPDATE)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private String updateBy;

    @TableField(value = DEL_FLAG)
    private Integer delFlag;
}
